package org.linys.dao.dict;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
import org.linys.model.dict.Dictionary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@SuppressWarnings("unchecked")
@Repository
public class DictionaryDAO {
	private SqlSession sqlSession;
	@Autowired
	public void setSqlSession(SqlSession sqlSession) {
		this.sqlSession = sqlSession;
	}
	
	
	public List<Dictionary> list(Dictionary dictionary,int offset, int limit) {
		return sqlSession.selectList("DictionaryMapper.list", dictionary,new RowBounds(offset,limit));
	}


	public void update(Dictionary dictionary) {
		sqlSession.update("DictionaryMapper.update", dictionary);
	}
	
	public Integer insert(Dictionary dictionary) {
		sqlSession.insert("DictionaryMapper.insert", dictionary);
		return dictionary.getDictionaryID();
	}

	public int count(Dictionary dictionary) {
		return (Integer)sqlSession.selectOne("DictionaryMapper.count", dictionary);
	}

	public int delete(Dictionary dictionary) {
		return sqlSession.delete("DictionaryMapper.delete",dictionary);
	}


	public int countChoose(Dictionary dictionary) {
		return (Integer) sqlSession.selectOne("DictionaryMapper.countChoose",dictionary);
	}


	public List<Dictionary> viewChoose(Dictionary dictionary, Integer start,
			Integer rows) {
		return (List<Dictionary>) sqlSession.selectList("DictionaryMapper.viewChoose",dictionary,new RowBounds(start,rows));
	}


	public Dictionary getByID(Dictionary dictionary) {
		return (Dictionary) sqlSession.selectOne("DictionaryMapper.getByID",dictionary);
	}
}
